package com.geek.gkbgw.web.local;

import com.geek.gkbgw.facade.abs.Response;
import com.geek.gkbgw.web.model.BaseResponse;

/**
 * 请输入一句美丽的描述话语
 *
 * @author hmilyylimh
 * ^_^
 * @version 0.0.1
 * ^_^
 * @date 2023/9/2 11:30
 */
public class ResponseThreadLocal {

    private static final ThreadLocal<Response> THREAD_LOCAL = new ThreadLocal<Response>();

    /**
     * <h2>将结果设置到当前本地线程中。</h2>
     *
     * @throws
     * @param: response
     * @return: void
     * @author hmilyylimh
     * @date: 2023/9/2
     */
    public static <T> void set(Response response) {
        THREAD_LOCAL.set(response);
    }

    /**
     * <h2>获取当前本地线程存储的响应对象。</h2>
     *
     * @throws
     * @param:
     * @return: com.geek.gkbgw.web.model.BaseResponse
     * @author hmilyylimh
     * @date: 2023/9/2
     */
    public static <T> BaseResponse get() {
        return (BaseResponse) THREAD_LOCAL.get();
    }

    /**
     * <h2>移除本地线程对象。</h2>
     *
     * @throws
     * @param:
     * @return: void
     * @author hmilyylimh
     * @date: 2023/9/2
     */
    public static void remove() {
        THREAD_LOCAL.remove();
    }
}
